<?php
/**
* TPL模板类--使用单例模式
*
* Copyright(c) 2012 by Tony. All rights reserved
* To contact the author write to {@link mailto:taonzy@163.com}
* @author Tony
*/
class TPL extends Smarty {
    static private $instance = null;       //用于存放实例化的对象
    //公共静态方法获取实例化的对象
    static public function getInstance() {
        if(!(self::$instance instanceof self)){
            self::$instance = new self();
        }
        return self::$instance;
    }
    //私有化克隆;单一职责问题,防止外部克隆对象
    private function __clone() {
    }
    private function __construct() {
        $this->setConfigs();
    }
    /*
     * 配置smarty参数
     */
    private function setConfigs() {
        $this->left_delimiter = SMARTY_LEFT_DELIMITER;
        $this->right_delimiter = SMARTY_RIGHT_DELIMITER;
        $this->template_dir = SMARTY_TEMPLATE_DIR;
        $this->compile_dir = SMARTY_COMPILE_DIR;
        $this->config_dir = SMARTY_CONFIG_DIR;
        $this->cache_dir = SMARTY_CACHE_DIR;
        $this->caching = SMARTY_CACHING;
        $this->cache_lifetime = SMARTY_CACHE_LIFETIME;
        $this->debugging = SMARTY_DEBUG;
    }
}